package com.ms.architecture.base

import android.util.SparseArray
import androidx.annotation.NonNull
import androidx.lifecycle.ViewModel

open class DataBindingConfig(
    @NonNull layout: Int,
    @NonNull vmVariableId: Int,
    @NonNull stateViewModel: ViewModel
) {
    private var layout = 0
    private var vmVariableId = 0
    private var stateViewModel: ViewModel? = null
    private val bindingParams = SparseArray<Any?>()

    init {
        this.layout = layout
        this.vmVariableId = vmVariableId
        this.stateViewModel = stateViewModel
    }

    open fun getLayout(): Int {
        return layout
    }

    open fun getVmVariableId(): Int {
        return vmVariableId
    }

    open fun getStateViewModel(): ViewModel? {
        return stateViewModel
    }

    open fun getBindingParams(): SparseArray<Any?>? {
        return bindingParams
    }

    open fun addBindingParam(variableId: Int, `object`: Any): DataBindingConfig? {
        if (bindingParams[variableId] == null) {
            bindingParams.put(variableId, `object`)
        }
        return this
    }
}